<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<%@ include file="/WEB-INF/views/include/easyui.jsp"%>
<script src="${ctx}/static/plugins/My97DatePicker/WdatePicker.js" type="text/javascript"></script>

</head>
<body style="font-family: '微软雅黑'">
<div id="tb" style="padding:5px;height:auto">
        <div>
        	<form id="searchFrom" action="">
       	        <input type="text" name="userName" class="easyui-validatebox" data-options="width:150,prompt: '姓名'"/>
       	        <input type="text" name="uid" class="easyui-validatebox" data-options="width:150,prompt: '理财师号'"/>
       	        <input type="text" name="telephone" class="easyui-validatebox" data-options="width:150,prompt: '手机号'"/>
       	        <input type="text" name="city" class="easyui-validatebox" data-options="width:150,prompt: '地区'"/>
       	        <input type="text" name="userDept" class="easyui-validatebox" data-options="width:150,prompt: '营业部'"/>
				<input type="text" name="beginDate" class="easyui-my97" datefmt="yyyy-MM-dd" data-options="width:150,prompt: '开始日期'"/>
				- <input type="text" name="endDate" class="easyui-my97" datefmt="yyyy-MM-dd" data-options="width:150,prompt: '结束日期'"/>
		        <span class="toolbar-item dialog-tool-separator"></span>
		        <a href="javascript(0)" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="cx()">查询</a>
			</form>
			<shiro:hasPermission name="lcs:buser:menu">
				<a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-edit" onclick="upd()">设置功能权限</a> 
				<span class="toolbar-item dialog-tool-separator"></span>
				<a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-edit" onclick="approve()">身份认证审核</a>
			</shiro:hasPermission>
        </div> 
        
</div>
<table id="dg"></table> 
<div id="dlg"></div>  
<div id="apv"></div>  
<script type="text/javascript">
var dg;
$(function(){   
	dg=$('#dg').datagrid({    
	method: "get",
    url:'${ctx}/user/json',

    fit : true,
	fitColumns : true,
	border : false,
	striped:true,
	idField : 'id',
	pagination:true,
	rownumbers:true,
	pageNumber:1,
	pageSize : 20,
	pageList : [ 10, 20, 30, 40, 50 ],
	singleSelect:true,
	sortRemote:false,
	queryParams:{
		sort: 'createTime',
		order: 'desc'
	},
    columns:[[
		{field:'id',title:'id',hidden:true},
		{field:'headImg',title:'头像',width:40,align:'center',formatter:function(value,rowData,rowIndex){
			if(rowData.headImg && rowData.headImg != '') {
				return '<img width="40" height="40" src="'+rowData.headImg+'" />';
			} else {
				return '<img width="40" height="40" src="${ctx}/static/images/headimg.png" />';
			}
			
		}},
		{field:'userName',title:'姓名',align:'center',sortable:false,width:50},
		{field:'uid',title:'理财师号',align:'center',sortable:false,width:50},
        {field:'telephone',title:'手机号',align:'center',sortable:false,width:60},
		{field:'city',title:'城市',align:'center',sortable:false,width:60},
        {field:'userDept',title:'营业部',align:'center',sortable:false,width:100},
        {field:'userDept2',title:'用户类型',align:'center',sortable:false,width:50,formatter:function(value,rowData,rowIndex){
			if(rowData.jxId && rowData.jxId.length == 10) {
				return "<span style='color: red;'>非信和</span>";
			} else {
				return "<span style='color: green;'>信和</span>";
			}
		}},
		{field:'marketShow',title:'营销模版功能',align:'center',sortable:false,width:50,formatter:function(value,rowData,rowIndex){
			if(value == '0') {
				return "<span style='color: red;'>未开通</span>";
			} else {
				return "<span style='color: green;'>已开通</span>";
			}
		}},
		{field:'lbsShow',title:'LBS功能',align:'center',sortable:false,width:50,formatter:function(value,rowData,rowIndex){
			if(value == '0') {
				return "<span style='color: red;'>未开通</span>";
			} else {
				return "<span style='color: green;'>已开通</span>";
			}
		}},
		{field:'profileStatus',title:'认证状态',align:'center',sortable:false,width:50,formatter:function(value,rowData,rowIndex){
			if(value == '2') {
				return "<span style='color: green;'>认证通过</span>";
			} else if(value == '1') {
				return "<span style='color: red;'>正在审核</span>";
			} else {
				return "未认证";
			}
		}},
        {field:'createTime',title:'注册时间',width:80,align:'center',sortable:false,formatter:function(value,rowData,rowIndex){
			return formatTime(value);
		}}
    ]],
    enableHeaderClickMenu: false,
    enableHeaderContextMenu: false,
    enableRowContextMenu: false,
    toolbar:'#tb'
	});
});

//创建查询对象并查询
function cx(){
	var obj=$("#searchFrom").serializeObject();
	obj.userName = encodeURIComponent(obj.userName);
	obj.city = encodeURIComponent(obj.city);
	obj.userDept = encodeURIComponent(obj.userDept);
	dg.datagrid('reload',obj); 
}
//修改
function upd(){
	var row = dg.treegrid('getSelected');
	if(rowIsNull(row)) return;
	//父级权限
	parentPermId=row.pid;
	d=$("#dlg").dialog({
		title: '修改功能权限',
		width: 300,
		height: 140,
		href:'${ctx}/user/update/'+row.id,
		maximizable:true,
		modal:true,
		buttons:[{
			text:'确认',
			handler:function(){
				$("#mainform").submit();
			}
		},{
			text:'取消',
			handler:function(){
				d.panel('close');
			}
		}]
	});

}
//用户身份审核查询
function approve(){
	var row = dg.treegrid('getSelected');
	if(rowIsNull(row)) return;
	//父级权限
	if(row.profileStatus == 0) {
		parent.$.messager.alert('该用户未提交认证信息！');
		return;
	}
	/*
	if(row.profileStatus == 2) {
		parent.$.messager.alert('该用户已通过认证！');
		return;
	}
	*/
	parentPermId=row.pid;
	d=$("#apv").dialog({
		title: '身份审核',
		width: 420,
		height: 300,
		href:'${ctx}/user/approve/'+row.id,
		maximizable:true,
		modal:true,
		buttons:[{
			text:'审核通过',
			handler:function(){
				parent.$.messager.confirm('提示', '确认该理财师身份审核通过么？', function(data){
					if (data){
						$.ajax({
							type:'post',
							data:{id:row.id, profileStatus:'2'},
							url:"${ctx}/user/approve",
							success: function(data){
								d.panel('close');
								dg.datagrid('reload');
							}
						});
					} 
				});
			}
		},{
			text:'审核不通过',
			handler:function(){
				parent.$.messager.confirm('提示', '确认该理财师身份审核不通过么？', function(data){
					if (data){
						$.ajax({
							type:'post',
							data:{id:row.id, profileStatus:'0'},
							url:"${ctx}/user/approve",
							success: function(data){
								d.panel('close');
								dg.datagrid('reload');
							}
						});
					} 
				});
			}
		},{
			text:'取消',
			handler:function(){
				d.panel('close');
			}
		}]
	});

}
</script>
</body>
</html>